package com.example.eback.entity.Proj;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;

import javax.persistence.*;
import java.io.IOException;

/**
 * Description: 需要注意的是创建需要调用node服务器的函数creat
 * @author: Pu Bowei
 * @date: 2023/6/10 21:30
 * @param:
 * @return:
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "quill")
@ToString
@JsonIgnoreProperties({"handler","hibernateLazyInitializer"})
public class Quill {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private int id;
    private String collage;//集合名（随机乱数）

    private int fid;//所属父类的id

    private  String doc;//文档名（随机乱数）

    private double x;
    private double y;
    private double z;

    public HttpResponse creatDoc(String collection,String document) throws IOException{
        HttpClient httpClient = HttpClientBuilder.create().build();
        String url="http://127.0.0.1:8080/creat?collection="+collection+"&document="+document;
        HttpGet request = new HttpGet(url);
        HttpResponse response = httpClient.execute(request);
        return  response;
    }
}
